package com.ys.controller.api.flow;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ys.entity.flow.YspModel;
import com.ys.service.flow.YspModelService;
import com.ys.service.sys.CommonApiService;
import com.ys.vo.LayuiTableVoJA;
import com.ys.vo.R;

@Controller
@RequestMapping("/api/inter/yspModel")
public class ApiInterYspModelController {
	
//	private static final Logger logger = Logger.getLogger(ApiAdminLoginController.class);
	
	@Autowired
	private CommonApiService<YspModel> commonApiService;
	@Autowired
	private YspModelService yspModelService;

//	@RequiresPermissions("ysModalSelector:view")
	@RequestMapping("/search")
    @ResponseBody
	public LayuiTableVoJA search(Model model, HttpServletRequest request, HttpServletResponse response,
			@ModelAttribute YspModel cond
			){
		
		cond.setStatus(1);
		
		return commonApiService.searchLay(cond);
	}
	
	/**
	 * 新增
	 */
	@PostMapping("/add")
	@ResponseBody
	public R add(HttpServletRequest request, @RequestParam Map<String, Object> params){
		return yspModelService.add(params);
	}
	
	/**
	 * 保存
	 */
	@PostMapping("/save")
	@ResponseBody
	public R save(HttpServletRequest request,
			@RequestBody String body){
		return yspModelService.save(body);
	}
	
	/**
	 * 部署
	 */
	@PostMapping("/deploy")
	@ResponseBody
	public R deploy(HttpServletRequest request,
			Long id){
		return yspModelService.deploy(id);
	}
	
	/**
	 * 删除
	 */
	@PostMapping("/delete")
	@ResponseBody
	public R delete(HttpServletRequest request,
			Long id){
		return yspModelService.delete(id);
	}
	
}
